package com.mobialia.socialmediademo;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

import android.util.Log;

public class Utils {
	public final static String TAG = "Utils";

	public static String convertStreamToString(InputStream is) throws IOException {
		Log.e(TAG, "convertStreamToString()");
		if (is != null) {
			StringBuilder sb = new StringBuilder();
			String line;

			try {
				BufferedReader reader = new BufferedReader(
						new InputStreamReader(is, "UTF-8"));
				while ((line = reader.readLine()) != null) {
					sb.append(line).append("\n");
				}
			} finally {
				is.close();
			}
			return sb.toString();
		} else {
			Log.e(TAG, "Error obtaining data!!!");
			return "";
		}
	}
}
